using MediatR;
using S.M.SmartMedical.ErrorCode;
using S.M.SmartMedical.Domain.Enums;

namespace S.M.SmartMedical.API.Write.Application.Command;

/// <summary>
/// 提交开单申请命令
/// </summary>
public class SubmitOrderApplicationCommand : IRequest<APIResult<OrderApplicationResultDto>>
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }
    
    /// <summary>
    /// 院区ID
    /// </summary>
    public int HospitalAreaId { get; set; }
    
    /// <summary>
    /// 申请项目列表
    /// </summary>
    public List<OrderApplicationItemDto> Items { get; set; } = new();
    
    /// <summary>
    /// 备注信息
    /// </summary>
    public string? Remarks { get; set; }
    
    /// <summary>
    /// 预约日期（可选）
    /// </summary>
    public DateTime? AppointmentDate { get; set; }
    
    /// <summary>
    /// 预约时间段（可选）
    /// </summary>
    public string? AppointmentTimeSlot { get; set; }
    
    /// <summary>
    /// 联系电话
    /// </summary>
    public string? ContactPhone { get; set; }
}

/// <summary>
/// 开单申请项目数据传输对象
/// </summary>
public class OrderApplicationItemDto
{
    /// <summary>
    /// 医疗项目ID
    /// </summary>
    public int MedicalProjectId { get; set; }
    
    /// <summary>
    /// 项目数量
    /// </summary>
    public int Quantity { get; set; } = 1;
}

/// <summary>
/// 开单申请结果数据传输对象
/// </summary>
public class OrderApplicationResultDto
{
    /// <summary>
    /// 申请ID
    /// </summary>
    public int Id { get; set; }
    
    /// <summary>
    /// 申请编号
    /// </summary>
    public string ApplicationNumber { get; set; } = string.Empty;
    
    /// <summary>
    /// 申请状态
    /// </summary>
    public int Status { get; set; }
    
    /// <summary>
    /// 项目总数量
    /// </summary>
    public int ProjectCount { get; set; }
    
    /// <summary>
    /// 总金额
    /// </summary>
    public decimal TotalAmount { get; set; }
    
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }
    
    /// <summary>
    /// 申请项目详情列表
    /// </summary>
    public List<OrderApplicationItemResultDto> Items { get; set; } = new();
}

/// <summary>
/// 开单申请项目结果数据传输对象
/// </summary>
public class OrderApplicationItemResultDto
{
    /// <summary>
    /// 项目ID
    /// </summary>
    public int Id { get; set; }
    
    /// <summary>
    /// 医疗项目ID
    /// </summary>
    public int MedicalProjectId { get; set; }
    
    /// <summary>
    /// 项目名称
    /// </summary>
    public string ProjectName { get; set; } = string.Empty;
    
    /// <summary>
    /// 项目价格
    /// </summary>
    public decimal ProjectPrice { get; set; }
    
    /// <summary>
    /// 项目描述
    /// </summary>
    public string? ProjectDescription { get; set; }
    
    /// <summary>
    /// 数量
    /// </summary>
    public int Quantity { get; set; }
    
    /// <summary>
    /// 小计金额
    /// </summary>
    public decimal SubTotal { get; set; }
}